using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Elo.Exemplo.EFCodeFirst.Domain.Entities;

namespace Elo.Exemplo.EFCodeFirst.Domain.Mapping
{
	public class ShipperMap : EntityTypeConfiguration<Shipper>
	{
		public ShipperMap()
		{
			// Primary Key
			this.HasKey(t => t.ShipperID);

			// Properties
			this.Property(t => t.CompanyName)
				.IsRequired()
				.HasMaxLength(40);
				
			this.Property(t => t.Phone)
				.HasMaxLength(24);
				
			// Table & Column Mappings
			this.ToTable("Shippers");
			this.Property(t => t.ShipperID).HasColumnName("ShipperID");
			this.Property(t => t.CompanyName).HasColumnName("CompanyName");
			this.Property(t => t.Phone).HasColumnName("Phone");
		}
	}
}

